package com.shigu.annotations;

import com.shigu.validation.tags.Telephone;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.regex.Pattern;

/*
 * create by  过儿  2019-07-08
 *
 */
public class PhoneCheckValidationImpl implements ConstraintValidator<PhoneCheck, String> {

    public PhoneCheckValidationImpl() {
    }

    public void initialize(PhoneCheck constraintAnnotation) {
    }

    public boolean isValid(String value, ConstraintValidatorContext context) {
        String telephonePartten ="^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\\d{8}$";
        return Pattern.matches(telephonePartten, value);
    }
}
